Pair Methods

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Syntax

C#
[SerializableAttribute]
public struct Pair<TFirst, TSecond>
Visual Basic (Declaration)
<SerializableAttribute> _
Public Structure Pair(Of TFirst, TSecond)
Visual C++
[SerializableAttribute]
generic<typename TFirst, typename TSecond>
public value class Pair

Type Parameters

TFirst
TSecond

The type exposes the following methods.

Public Methods

  NameDescription
Public methodCompareTo

Compares this pair to another pair of the some type. The pairs are compared by using the IComparable<T> or IComparable interface on TFirst and TSecond. The pairs are compared by their first elements first, if their first elements are equal, then they are compared by their second elements.

If either TFirst or TSecond does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the pairs cannot be compared.

Public operatorStatic memberEquality
Determines if two pairs are equal. Two pairs are equal if the first and second elements both compare equal using IComparable<T>.Equals or object.Equals.
Public methodEqualsOverloaded.
Public operatorStatic memberExplicitOverloaded.
Public methodGetHashCode
Returns a hash code for the pair, suitable for use in a hash-table or other hashed collection. Two pairs that compare equal (using Equals) will have the same hash code. The hash code for the pair is derived by combining the hash codes for each of the two elements of the pair.
(Overrides ValueType..::GetHashCode()().)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public operatorStatic memberInequality
Determines if two pairs are not equal. Two pairs are equal if the first and second elements both compare equal using IComparable<T>.Equals or object.Equals.
Public methodToKeyValuePair
Converts this Pair to a KeyValuePair. The Key part of the KeyValuePair gets the First element, and the Value part of the KeyValuePair gets the Second elements.
Public methodToString
Returns a string representation of the pair. The string representation of the pair is of the form: First: {0}, Second: {1} where {0} is the result of First.ToString(), and {1} is the result of Second.ToString() (or "null" if they are null.)
(Overrides ValueType..::ToString()().)

Protected Methods

  NameDescription
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)

Explicit Interface Implementations

  NameDescription
Explicit interface implemetationPrivate methodIComparable..::CompareTo

Compares this pair to another pair of the some type. The pairs are compared by using the IComparable<T> or IComparable interface on TFirst and TSecond. The pairs are compared by their first elements first, if their first elements are equal, then they are compared by their second elements.

If either TFirst or TSecond does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the pairs cannot be compared.

See Also